<template>
  <div class="index-box" ref="index" v-loading="loading">
    <div class="backBox">
        <span class="back" @click="back"><i class="el-icon-back"></i>返回</span>
    </div>
    <div class="topBox d-flex">
      <el-card class="box-card flex1">
        <div slot="header" class="clearfix">
          <span>商品信息</span>
        </div>
           <el-form class="margin-top" label-position="right">
             <el-form-item label-width="125px"  label="订单号:">{{orderInfo.orderNo}}</el-form-item>
             <el-form-item label-width="125px"  label="商品图片:"> <el-image :src="shopImg" fit="fill" v-image-preview class="img"></el-image></el-form-item>
             <el-form-item label-width="125px"  label="商品编号:">{{orderInfo.orderId}}</el-form-item>
             <el-form-item label-width="125px"  label="商品标题:">{{goodsName}}</el-form-item>
             <!-- <el-form-item label-width="125px"  label="商品分类:">云仓订单</el-form-item> -->
             <el-form-item label-width="125px"  label="零售价(元):">{{orderItemList.salePrice}}</el-form-item>
             <el-form-item label-width="125px"  label="订单来源:">云仓好货</el-form-item>
           </el-form>


      </el-card>
      <el-card class="box-card flex1" style="margin:0 20px;" >
        <div slot="header" class="clearfix">
          <span>订单信息</span>
        </div>
           <el-form class="margin-top" :column="1" >
             <el-form-item label-width="125px"  label="购买数量:"><span class="red">{{orderItemList.goodsNum}}</span>件</el-form-item>
             <el-form-item label-width="125px"  label="订单总价(元):"><span class="red">{{orderInfo.goodsTotalPrice}}</span></el-form-item>
             <el-form-item label-width="125px"  label="已付款(含运费):"><span class="red">{{orderInfo.actualPay}}</span></el-form-item>
             <el-form-item label-width="125px"  label="购买人:">{{orderInfo.buyUserName}}【{{orderInfo.telephone}}】</el-form-item>
             <el-form-item label-width="125px"  label="收货人:">{{orderInfo.receiveUser}}【{{orderInfo.receivePhone}}】</el-form-item>
             <el-form-item label-width="125px"  label="收货地址:">{{orderInfo.receiveAddress}}</el-form-item>
             <el-form-item label-width="125px"  label="订单备注:">{{orderInfo.remarks}}</el-form-item>
             <el-form-item label-width="125px"  label="真实姓名:">{{orderInfo.fullname}}</el-form-item>
             <el-form-item label-width="125px"  label="身份证号:">{{orderInfo.idcardNumber}}</el-form-item>
           </el-form>
      </el-card>
      <el-card class="box-card flex1">
        <div slot="header" class="clearfix">
          <span>订单进度</span>
        </div>
           <el-form  :model="dataList" label-position="right" >
             <el-form-item label="创建时间:"  label-width="125px" >
                  {{ parseTime(orderInfo.createTime) }}
             </el-form-item>
             <el-form-item label="物流公司:"  label-width="125px">
                 {{orderInfo.expressName}}
             </el-form-item>
             <el-form-item label="运单号码:"  label-width="125px">
                 {{orderInfo.expressNumber}}
             </el-form-item>
             <el-form-item label="发货时间:"  label-width="125px">
                {{ parseTime(orderInfo.shipmentTime) }}
             </el-form-item>
             <el-form-item label="完成时间:"  label-width="125px">
                {{ parseTime(orderInfo.completeTime) }}
             </el-form-item>
             <div class="flow">
               <el-timeline >
                 <el-timeline-item
                   v-for="(activity, index) in logisticsList"
                   :key="index"
                   :color="index=='0'?'#FF6A18':'#909399'"
                   :timestamp="activity.acceptStation">
                   <div :style="{color:(index=='0'?'#FF6A18':'#909399')}">
                      <span class="status" style="margin-right:8px;font-size: 16px;">{{activity.actionName}}</span><span class="time">{{activity.acceptTime}}</span>
                   </div>

                 </el-timeline-item>
               </el-timeline>
             </div>
           </el-form>
      </el-card>
    </div>
    <div class="centerBox">

    </div>
    <div class="bottomBox">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>候鸟订单</span>
          <span class="red" style="margin-left:20px">订单提交失败原因:</span>
          <span class="red">保税和直邮商品，收件人必须为中文且为真实姓名</span>
        </div>
        <el-table :data="orderList" style="width: 100%"  border stripe>
          <el-table-column prop="name" label="序号">
            <template #default="scope">
              <span>1</span>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="候鸟订单号">
            <template #default="scope">
              <span>{{orderNo}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="sku" label="商品(规格SKU)"></el-table-column>
          <el-table-column prop="name" label="商品(价格)">
            <template #default="scope">
              <span class="red">¥{{orderItemList.salePrice}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="商品(数量)">
            <template #default="scope">
              X{{orderItemList.goodsNum}}
            </template>
          </el-table-column>
          <el-table-column prop="name" label="小计">
            <template #default="scope">
              <span class="red">¥{{orderInfo.actualPay}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="状态">
            <template #default="scope">
              <span>{{orderInfo.statusName}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="更新时间">
            <template #default="scope">
              <span>{{parseTime(orderInfo.createTime)}}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
    </div>
  </div>
</template>

<script>
  import common from '@/api/api';
  import {
    orderRead, getLogisticsTrack
  } from '@/api/getData'
  import option from '../../common/option.js';

  export default {
    data() {
      return {
        loading: false,
        orderNo:'',
        orderList:[{name:'仟枝氧牌抗菌液'}],/*候鸟订单数据*/
        orderInfo:{},
        orderItemList:{},
        shopImg:'',
        goodsName:'',
        dataList:{name:'仟枝氧牌抗菌液10ml',img:'https://cu.shcoolmeal.com/qianzhi_common/upload/cache/images/2021/08_29/f7b3762431648e1b9fed55e9929e1a77_60x60.jpg'},
        logisticsList:[],//物流信息
      }
    },

    mounted() {
      this.dataInfo();
      this.getHNLogisticsFn();
    },
    methods: {
      back(){
          this.$router.go(-1);//返回上一层
      },
      getHNLogisticsFn(){
        getLogisticsTrack({orderId:this.$route.query.id}).then((result)=>{
        		if (result.code == 200) {
             this.logisticsList = result.data.logisticsTrack;
            } else {
              //this.$message.error(result.msg);
              this.logisticsList = [];
            }
        })
      },
      async dataInfo() {
        try {
          this.loading = true;
          const result = await orderRead({orderId:this.$route.query.id});
          if (result.code == 200) {
            this.afterSaleList = result.data.orderAfterSale;
            this.attachmentInfoList = result.data.attachmentInfoList;
            this.orderItemList = result.data.orderItemList[0];
            this.orderItemList.goodsInfo = JSON.parse(this.orderItemList.goodsInfo);
            this.shopLength = result.data.orderItemList.length;
            this.orderInfo = result.data.orderInfo;
            let list = [];
            list.push(this.orderItemList.goodsInfo);
            console.log(list)
            this.orderList = list;
            this.orderNo = JSON.parse(result.data.orderInfo.hnOrderItem).orderNo

            this.shopImg = this.orderItemList.goodsInfo.picLibUrl + this.orderItemList.goodsInfo.big;
            if(!this.shopImg){
              this.shopImg = this.orderItemList.goodsInfo.goodsImg.img
            }
            this.goodsName = this.orderItemList.goodsInfo.goodsName;
          } else {
            this.$message.error(result.msg);
          }
          this.loading = false;
        } catch (err) {
          this.loading = false;
          console.log(err)
        }
      },

    }
  }
</script>

<style scoped lang="scss">
  .flow /deep/ .el-timeline-item:first-child .el-timeline-item__content{
    color:#FF6A18
  }
  .flow /deep/ .el-timeline-item__timestamp{
    margin-top:4px;
    line-height: 1.5;
  }
  .flow{
        padding-left: 53px;
        padding-top: 10px;
  }
  .index-box /deep/ .el-form-item{
    margin-bottom:10px;
  }
  .index-box{
    height: 100%;
    overflow-y: auto;
  }
  .backBox{
    margin-bottom: 10px;
  }
  .img{
    width: 100px;
  }
  .main{
    display: flex;
    flex-wrap: wrap;
    .chunk-box{
      width: 33%;
      padding: 10px 0;
    }
  }
  .main /deep/ .el-form-item{
    margin-bottom: 10px!important;
  }
  .time p{
    font-size: 14px;
    color: #606266;
    font-weight: 700;
  }
  .time{
     padding-left:60px!important;
  }
  $myColor: #606266;
  .main /deep/ .el-step__line{
    background-color: $myColor;
  }
  .main /deep/ .el-steps,.main /deep/ .el-step__icon-inner{
    color:$myColor;
  }
  .main /deep/ .el-step__title{
    color:$myColor;
    font-size: 14px;
    font-weight: 700;
  }
  .main /deep/ .el-step__icon.is-text{
    border: 2px solid $myColor;
  }
  .centerBox /deep/ .el-steps--vertical{
    height:200px;
  }
  .centerBox{
    margin:20px 0;
  }
</style>
